package states 
{
  import flash.text.TextField;
  import org.agony2d.control.KeyboardManager;
  import org.agony2d.notify.AEvent;
  import org.agony2d.view.ProgressBar;
  import org.agony2d.view.UIState
	
	public class RangeUIState extends UIState
	{
		
		override public function enter() : void
		{
			var progress:ProgressBar
			
			progress = new ProgressBar('Range_A')
			this.fusion.addElement(progress, 200, 200)
			
			var txt:TextField = new TextField()
			txt.y = -40
			progress.container.addChild(txt)
			progress.range.addEventListener(AEvent.CHANGE,function(e:AEvent):void
			{
				txt.text = String(progress.range.value)
			})
			
			KeyboardManager.getInstance().getState().press.addEventListener('A', function():void
			{
				progress.range.value -= 10
			})
			KeyboardManager.getInstance().getState().press.addEventListener('D', function():void
			{
				progress.range.value += 10
			})
		}
		
		override public function exit() : void
		{
			KeyboardManager.getInstance().getState().press.removeAllEventListeners('A')
			KeyboardManager.getInstance().getState().press.removeAllEventListeners('D')
		}
	}
}